package com.jshop.seckill.web.controller;

import com.jshop.seckill.domain.TbUser;
import com.jshop.seckill.http.HttpResult;
import com.jshop.seckill.web.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/login")
public class LoginController {

    //注入服务
    @Autowired
    private UserService userService;

    /**
     * @Description: 系统登录
     */
    @RequestMapping(value = "/login",method = RequestMethod.POST)
    public HttpResult login(@RequestBody TbUser frontUser){
        HttpResult result = userService.login(frontUser);
        return result;
    }

    /**
     * @Description: 根据token获取用户信息
     */
    @RequestMapping("/getLoginUser/{token}")
    public HttpResult getUserInfo(@PathVariable String token){
        //根据token查询用户信息
        TbUser frontUser = userService.getUserInfoFromCache(token);
        return HttpResult.ok(frontUser);
    }
    /**
     * 短信验证码登录
     */
    /**
     * 退出登录功能
     */
    /**
     * 发送短信验证码
     */
    /**
     * 校验用户名是否可以方法
     */
    /**
     * 用户注册功能
     */
}

